#ifndef _CLIENT_H_
#define _CLIENT_H_

#include <string>
#include "staffmqclientexport.h"

namespace staff
{
  class CDataObject;
}

namespace smq
{
  struct Message;

  //! smq server client
  /*! internal class, implementing transport */
  class STAFFMQ_CLIENT_EXPORT Client
  {
  public:
    Client();
    ~Client();

    //! initialize and connect to queue server
    /*! \param  sServerHost - queue server host
        \param  ushServerPort - queue server port
      */
    void Init(const std::string& sServerHost = "127.0.0.1", unsigned short ushServerPort = 8768);

    //! break post or receive progress
    void Shutdown();
    
    //! close connection with server
    void Close();
    
    //! is client currently closing
    /*! \return true, if Close() function was called
      */
    bool IsShuttingDown() const;

    //! post message to server
    /*! \param rMsg - message to post
      */
    void Post(const staff::CDataObject& rMsg);

    //! receive message from server
    /*! \param rMsg - received message
        \param bIsMessage - true-receive message object only,
                            false-receive response and fault only
      */
    void Receive(staff::CDataObject& rMsg, bool bIsMessage);

  private:
    struct ClientImpl;
    ClientImpl* m_pImpl;
  };
}

#endif // _CLIENT_H_
